package com.degani.pdf;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

import org.apache.log4j.Logger;

public class FieldMap extends HashMap<String, String> {
	private static Logger logger = Logger.getLogger(FieldMap.class);
	private static final long serialVersionUID = 1L;

	public synchronized void load(InputStream inStream) throws IOException
	{
		String line;
		BufferedReader r = new BufferedReader(new InputStreamReader(inStream));
		while ((line = r.readLine()) != null)   {
			String[] split = line.split("=");
			if(split.length == 1){
				put(split[0], null);
			} else if(split.length == 2){
				put(split[0],split[1]);			
			} else {
				logger.error("Error while parsing:%s. Could not determine key and value - skipping");
			}
		}
	}
}
